#include<iostream>
#include<cstdio>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>

int main()
{
    pid_t id = fork();
    if(id == 0)
    {
        char *const argv[] = 
        {
            (char*)"ls",
            (char*)"--color",
            (char*)"-l",
            (char*)"-a",
            nullptr
        };
        execv("/usr/bin/ls",argv);
        //sleep(3);
        //child
        //execl("/bin/ls","ls","-l","-a","--color",nullptr);
        //exit(1);
    }

    //father
    pid_t rid = waitpid(id, nullptr, 0);
    if(rid > 0)
    {
        printf("等待子进程成功！\n");
    }
    return 0;
    //printf("我是myexec,pid : %d\n",getpid());
    //int n = execl("/bin/ls","ls","-l","-a","--color",nullptr);
    //printf("execl return val : %d\n",n);
    //execl("./other", "other",nullptr);
}
